<%@codepage="65001"%>
<%session.codepage="65001"%>
<!-- #include virtual=/inc/dbConn.asp -->
<!-- #include virtual=/inc/function.asp -->
<!-- #include virtual=/inc/action.header.inc.asp -->

<%
	'## 파라미터 변수 선언부
	equipCd		= Request("findEquipCd")
	fullLotNo	= Request("findLotNo")
	startDt		= Request("findStartDt")
	endDt		= Request("findEndDt")
	listMode	= Request("listMode")
	
	SQLTitle = "-- ■■■■ 장비휴지 그리드 List up ■■■■"
	
	'## 검색조건에 따른 조건절 만들기 
	If equipCd <> "" Then 
		addSql = " A.equipCd='" & equipCd & "' "
	End If 
	If fullLotNo <> "" Then 
		If addSql <> "" Then addSql = addSql & " AND "
		addSql = addSql & " A.fullLotNo LIKE '%" & fullLotNo & "%' "
	End If 	
	If startDt <> "" Then 
		If addSql <> "" Then addSql = addSql & " AND "
		addSql = addSql & " A.breakDt >= '" & startDt & "' "
	End If 	
	If endDt <> "" Then 
		If addSql <> "" Then addSql = addSql & " AND "
		addSql = addSql & " A.breakDt <= '" & endDt & "' "
	End If 
	If listMode <> "" Then 
		If addSql <> "" Then addSql = addSql & " AND "
		addSql = addSql & " A.flag = 'Y' "
	End If 

	If addSql <> "" Then 
		addSql = " WHERE " & addSql 
	End If 

	If listMode = "" Then 
		SQL = "SELECT A.seq, B.itemNm, A.breakDt, A.breakTm, A.fullLotNo, A.flag FROM tblEquipBreak A LEFT JOIN (SELECT itemCd, itemNm FROM tblComCode WHERE groupCd='0001') B ON A.equipCd=B.itemCd" & addSql & " ORDER BY A.breakDt DESC" 
	Else
		SQL = "SELECT 0 seq, B.itemNm, A.breakDt, SUM(A.breakTm) breakTm, A.fullLotNo, A.flag FROM tblEquipBreak A LEFT JOIN (SELECT itemCd, itemNm FROM tblComCode WHERE groupCd='0001') B ON A.equipCd=B.itemCd " & addSql & " GROUP BY  B.itemNm, A.breakDt, A.fullLotNo, A.flag ORDER BY A.breakDt DESC" 
	End If 

	If xMode="debug" Then 
		Call showDebug(SQLTitle,SQL) 
	End If 

	Set Rs=Server.CreateObject("ADODB.RecordSet")
	Rs.open SQL, DbCon, 1
	
	Response.write "<Equipment>" & vbcrlf

	If Rs.eof Or Rs.bof Then 
	Else 
		Do Until Rs.eof Or Rs.bof
		
			Response.write "	<BreakList>" & vbcrlf
				Call mkXMLNode("seq", rs("seq"), 2)
				Call mkXMLNode("itemNm", rs("itemNm"), 2)
				Call mkXMLNode("breakDt", rs("breakDt"), 2)
				Call mkXMLNode("breakTm", rs("breakTm"), 2)
				Call mkXMLNode("fullLotNo", rs("fullLotNo"), 2)
				Call mkXMLNode("flag", rs("flag"), 2)
			Response.write "	</BreakList>" & vbcrlf

		Rs.movenext
		Loop 
	End If
	Response.write "</Equipment>" & vbcrlf
'	Call rsWithXML("Save OK!")
%>